﻿using Kw.Combinatorics;
using System;

namespace Kw.CombinatoricsExamples
{
    // Subclassing is one way to get user-friendly output.
    public class Fruits : Combination
    {
        public static readonly string[] names = new string[] { "apple", "banana", "cherry", "durian" };

        public Fruits ()
            : base (names.Length)
        { }

        public override string ToString ()
        {
            string result = "";
            foreach (int element in this)
                result += names[element] + " ";
            return result;
        }
    }

    class CombinationExample02
    {
        static void Main ()
        {
            foreach (var combo in new Fruits ().AllPicks)
                Console.WriteLine (combo);
        }

        /* Output:

        apple
        banana
        cherry
        durian
        apple banana
        apple cherry
        apple durian
        banana cherry
        banana durian
        cherry durian
        apple banana cherry
        apple banana durian
        apple cherry durian
        banana cherry durian
        apple banana cherry durian

        */
    }
}
